<template>
	<div id="news_detail" class="table" v-if="formVisible">
		<div class="container">
			<div style="text-align:center;">
				<div style="text-align:left;margin:0 auto;">
					<el-form :model="modelData" label-width="120px" class="demo-ruleForm">						
						<div class="rows">
							<el-form-item label="投资人：">
								<el-select v-model="modelData.investor" placeholder="请选择">
									<el-option v-for="item in customers" :key="item.id" :label="item.realName" :value="item.id"></el-option>
								</el-select>
							</el-form-item>
							<el-form-item class="text_align" label="融资金额：">
								<el-input v-model="modelData.investPrice" :maxlength="100"></el-input>
							</el-form-item>
							<!--<el-form-item label="融资轮次：">
								<el-select v-model="modelData.investTag" placeholder="请选择">
									<el-option v-for="(value,key) in investTags" :key="key" :label="value" :value="key"></el-option>
								</el-select>
							</el-form-item>-->
						</div>
						<div class="rows">							
							<el-form-item class="text_align" label="股权占比：">
								<el-input v-model="modelData.shareRatio" :maxlength="100"></el-input>
							</el-form-item>
							<div></div>
						</div>						
					</el-form>
				</div>
			</div>
			<div style="clear:both;"></div>
			<div slot="footer" class="dialog-footer my_flex_right">
				<el-button @click="close()">返回</el-button>
				<el-button type="primary" @click="save()">保存</el-button>
			</div>
		</div>
	</div>
</template>

<script>
	import service from '@/js/services/projectinvestservice.js';
	import customerservice from '../../../js/common/customerservice.js';
	export default {
		props: {
			id: 0,
			proId:0,
			parentDetailData: {}
		},
		data() {
			return {
				modelData: {},
				customers: [],
				selectedjobs: [],
				formVisible: false,
				investTags: []
			}
		},
		watch: {
			formVisible(newVal, oldVal) {
				if(newVal) { //详情页弹出
					this.resetData();
					let self = this;
					let param_arr = ['invest']; //融资轮次
					this.tool.getDirByKey(this, param_arr).then(() => {
						self.investTags = self.$store.state.invest;
					});					
					customerservice.getAll(this, function(res) {
						self.customers = res.data; //机构
					});
					if(this.id){
						service.getModelData(this);
					}					
				}
			},
		},
		created() {

		},
		mounted() {},
		methods: {
			resetData() {
				this.modelData = {
					id: null,
					productId:this.proId,
					investor: null,
//					investTag: null,
					investPrice: null,
					shareRatio: null,
				};
				this.selectedjobs = [];
				this.selectedtags = [];
				this.fileList = [];
			},
			show() {
				this.formVisible = true;
			},
			save() {
				service.handleSave(this);
			},
			close() {
				this.parentDetailData.isTabelShow = true;
				this.formVisible = false;
			},
			handleAvatarSuccess(res, file) {
				if(res.code == 1) {
					this.modelData.logo = res.data.id;
				} else {
					this.$message({
						message: res.msg,
						type: 'error'
					});
				}
			},
			handleRemove(file, fileList) {
				this.modelData.bpAttactId = null;
				this.modelData.bpAttactName = null;
				this.fileList = [];
			},
			handleAvatarSuccess1(files, fileList) {
				this.modelData.bpAttactId = files.data.id;
				this.modelData.bpAttactName = files.data.fileOriginName;
				this.fileList = [];
				this.fileList.push({
					name: files.data.fileOriginName
				});
			},
			beforeAvatarUpload(file) {
				return this.validatetool.validateImgSizeAndType(this, file);
			},
			beforeAvatarUpload1(file) {
				return this.validatetool.validateImgSizeAndType(this, file, '.pdf', 4);
			}
		},

	}
</script>